
/**
 * copyright(c) 2013 www.jiongshibaoliao.com, All Rights Reserved.
 * project: jiongshibaoliao 
 * author: 曾帅
 * date: 2014-1-16 上午11:07:45
 * version: v1.0
 */

package com.jiongshibaoliao.service.impl;

import java.util.Date;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.jiongshibaoliao.dao.BaseDao;
import com.jiongshibaoliao.dao.UserDao;
import com.jiongshibaoliao.model.User;
import com.jiongshibaoliao.model.enums.ActiveStatus;
import com.jiongshibaoliao.model.enums.SingupSource;
import com.jiongshibaoliao.model.enums.UserType;
import com.jiongshibaoliao.service.UserService;

/**
 * @project jiongshibaoliao
 * @author 曾帅 
 * @version 1.0
 * @date 2014-1-16 上午11:07:45   
 */

@Service
public class UserServiceImpl extends BaseServiceImpl implements UserService {

	@Autowired
	public UserDao userDao;
	
	/**
	 * 
	 * @author 曾帅
	 * @version 1.0
	 * @date 2014-1-16 上午11:09:13
	 * @see com.jiongshibaoliao.service.impl.BaseServiceImpl#getDao()
	 */
	@Override
	public BaseDao getDao() {
		return userDao;
	}

	
	/**
	 * 
	 * @author 曾帅
	 * @version 1.0
	 * @date 2014-1-16 下午04:58:22
	 * @see com.jiongshibaoliao.service.UserService#findUserByLoginNameAndPwd(java.lang.String, java.lang.String)
	 */
	@Override
	public User findUserByLoginNameAndPwd(String loginName, String passWord) {
		return userDao.findUserByLoginNameAndPwd(loginName, passWord);
	}


	@Override
	public <T> void create(T entity) {
		User user = (User) entity;
		User _user = new User(user.getLoginName(), user.getNickName(), user
				.getPassWord(), user.getLoginName(), null, null, null, null,
				UserType.USER, ActiveStatus.ACTIVED, SingupSource.JIONG,
				new Date(), new Date(), 1);
		userDao.create(_user);
	}


	
	/**
	 * 
	 * @author 曾帅
	 * @version 1.0
	 * @date 2014-2-8 下午04:49:21
	 * @see com.jiongshibaoliao.service.UserService#getUserIdByLoginName(java.lang.String)
	 */
	@Override
	public long getUserIdByLoginName(String loginName) {
		return userDao.getUserIdByLoginName(loginName);
	}


	
	/**
	 * 
	 * @author 曾帅
	 * @version 1.0
	 * @date 2014-2-9 下午08:32:44
	 * @see com.jiongshibaoliao.service.UserService#isUserExist(java.lang.String)
	 */
	@Override
	public boolean isUserExist(String loginName) {
		return userDao.isUserExist(loginName);
	}
	
}
